home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / AmigaSystem / Scalos / GuiGFXLib / src / guigfx_rasthandle.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  3.8 KB  |  210 lines

  1. /*********************************************************************
  2. ----------------------------------------------------------------------
  3.  
  4.     guigfx_rasthandle
  5.  
  6. ----------------------------------------------------------------------
  7. *********************************************************************/
  8.  
  9. #include <render/render.h>
  10. #include <libraries/cybergraphics.h>
  11. #include <utility/tagitem.h>
  12. #include <graphics/gfx.h>
  13. #include <graphics/view.h>
  14.  
  15. #include <proto/render.h>
  16. #include <proto/graphics.h>
  17. #include <proto/exec.h>
  18. #include <proto/utility.h>
  19. #include <proto/cybergraphics.h>
  20.  
  21.  
  22. #include <guigfx/guigfx.h>
  23.  
  24. #include "guigfx_global.h"
  25. #include "guigfx_bitmap.h"
  26.  
  27.  
  28. /*--------------------------------------------------------------------
  29.  
  30.         DeleteRastHandle(rh)
  31.  
  32.         löscht ein RastHandle
  33.     
  34. --------------------------------------------------------------------*/
  35.  
  36. void DeleteRastHandle(RASTHANDLE *rh)
  37. {
  38.     if(rh->temprp)
  39.     {
  40.         if(rh->temprp->BitMap)
  41.         {
  42.             FreeBitMap(rh->temprp->BitMap);
  43.         }
  44.  
  45.         FreeRenderVec(rh->temprp);    
  46.     }
  47.     FreeRenderVec(rh);
  48. }
  49.  
  50.  
  51. /*--------------------------------------------------------------------
  52.  
  53.         rasthandle = CreateRastHandle(rp)
  54.  
  55.         ermittelt Rastport-Daten und erzeugt
  56.         ein RastHandle.
  57.     
  58. --------------------------------------------------------------------*/
  59.  
  60. RASTHANDLE *CreateRastHandle(struct RastPort *rp, ULONG modeID)
  61. {
  62.     RASTHANDLE *rh;
  63.  
  64.     int iscyber;
  65.     int depth;
  66.     int flags;
  67.     int width;
  68.  
  69.     BOOL success = FALSE;
  70.  
  71.     if (rh = AllocRenderVecClear(MemHandler,sizeof(RASTHANDLE)))
  72.     {
  73.         rh->rp = rp;
  74.         rh->drawmode = DRAWMODE_WRITEPIXELARRAY;
  75.         rh->truecolor = FALSE;
  76.         rh->colormode = COLORMODE_CLUT;
  77.  
  78.         GetBitMapInfo(rp->BitMap, modeID,
  79.             BMAPATTR_CyberGFX, &iscyber,
  80.             BMAPATTR_Depth, &depth,
  81.             BMAPATTR_Flags, &flags,
  82.             BMAPATTR_Width, &width,
  83.             TAG_DONE);
  84.  
  85.  
  86.         if (iscyber)
  87.         {
  88.             DB(kprintf("cyber bitmap detected\n"));
  89.  
  90.             rh->drawmode = DRAWMODE_CYBERGFX;
  91.             rh->truecolor = (depth > 8);
  92.         }
  93.  
  94.  
  95.         if (flags & BMF_STANDARD)
  96.         {
  97.             DB(kprintf("BMF_STANDARD bitmap detected\n"));
  98.  
  99.             if (env_usewpa8)
  100.             {
  101.                 rh->drawmode = DRAWMODE_WRITEPIXELARRAY;
  102.             }
  103.             else
  104.             {
  105.                 rh->drawmode = DRAWMODE_BITMAP;
  106.             }
  107.         }
  108.  
  109.  
  110.         if (rh->temprp = AllocRenderVec(MemHandler, sizeof(struct RastPort)))
  111.         {
  112.             TurboCopyMem(rp, rh->temprp, sizeof(struct RastPort));
  113.             rh->temprp->Layer = NULL;
  114.             if (rh->temprp->BitMap = AllocBitMap(width, 1, depth, 0, rp->BitMap))
  115.             {
  116.                 success = TRUE;
  117.             }
  118.         }
  119.  
  120.  
  121.  
  122.  
  123. /*
  124.         if(CyberGfxBase)
  125.         {
  126.             if (GetCyberMapAttr(rp->BitMap, CYBRMATTR_ISCYBERGFX))
  127.             {
  128.                 DB(kprintf("Cybergraphics bitmap detected\n"));
  129.                 rh->drawmode = DRAWMODE_CYBERGFX;
  130.                 rh->truecolor = (GetCyberMapAttr(rp->BitMap, CYBRMATTR_DEPTH) > 8);
  131.             }
  132.         }
  133.  
  134.  
  135.         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  136.  
  137.         if (GetBitMapAttr(rp->BitMap, BMA_FLAGS) & BMF_STANDARD)
  138.         {
  139.             DB(kprintf("BMF_STANDARD bitmap detected\n"));
  140.  
  141.             if (env_usewpa8)
  142.             {
  143.                 rh->drawmode = DRAWMODE_WRITEPIXELARRAY;
  144.             }
  145.             else
  146.             {
  147.                 rh->drawmode = DRAWMODE_BITMAP;
  148.             }
  149.         }
  150.  
  151.  
  152. //        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  153.  
  154.         if (rh->temprp = AllocRenderVec(MemHandler, sizeof(struct RastPort)))
  155.         {
  156.             ULONG width, depth;
  157.  
  158.             TurboCopyMem(rp, rh->temprp, sizeof(struct RastPort));
  159.             rh->temprp->Layer = NULL;
  160.             
  161.             width = GetBitMapAttr(rp->BitMap, BMA_WIDTH);
  162.             depth = GetBitMapAttr(rp->BitMap, BMA_DEPTH);
  163.             
  164.             if (rh->temprp->BitMap = AllocBitMap(width,1,depth,0,rp->BitMap))
  165.             {
  166.                 success = TRUE;
  167.             }
  168.         }
  169. */
  170.  
  171.  
  172.     }
  173.  
  174.     if (success)
  175.     {
  176.         if (modeID != INVALID_ID)
  177.         {
  178.             /* colormode (ggf. HAM) ermitteln */
  179.             
  180.             DisplayInfoHandle dih;
  181.             
  182.             if(dih = FindDisplayInfo(modeID))
  183.             {
  184.                 struct DisplayInfo di;    
  185.             
  186.                 if(GetDisplayInfoData(dih, (UBYTE*) &di, sizeof(di), DTAG_DISP, modeID))
  187.                 {
  188.                     if (di.PropertyFlags & DIPF_IS_HAM)
  189.                     {
  190.                         rh->colormode = (depth == 8) ?
  191.                             COLORMODE_HAM8 : COLORMODE_HAM6;
  192.                     }
  193.                 }
  194.             }
  195.  
  196.         }
  197.     }
  198.     else
  199.     {
  200.         if (rh)
  201.         {
  202.             DeleteRastHandle(rh);
  203.             rh = NULL;
  204.         }
  205.     }
  206.  
  207.     return rh;
  208. }
  209.  
  210.